<?php
/**
 * User: 1971229701@qq.com
 * Date: 2020/9/8/008
 * Time: 14:00
 */

namespace app\move\controller;


use app\move\logic\IndexLogic;
use think\App;
use think\Db;

class Index extends Base
{
    private $index_logic;

    public function __construct(App $app = null)
    {
        parent::__construct($app);
        $this->index_logic = new IndexLogic();
    }

    public function index($title = '',$type = '',$pid = '')
    {
        $banner = $this->index_logic->banner();
        $cate = $this->index_logic->cate();
        $lists = $this->index_logic->lists($title);
        $video = $this->index_logic->video($type,$pid);
        $this->assign('banner', $banner);
        $this->assign('cate', $cate);
        $this->assign('lists', $lists);
        $this->assign('video', $video);
        $this->assign('web_title','首页');
        return $this->fetch();
    }

    // 轮播图
    public function banner()
    {
        return $this->index_logic->banner();
    }

    // 全部车系
    public function cate()
    {
        return $this->index_logic->cate();
    }

    // 热门车型
    public function lists($params)
    {
        return $this->index_logic->lists($params);
    }

    // 评测视频
    public function video($params)
    {
        return $this->index_logic->video($params);
    }

    public function formsubmit()
    {
        $tel = $_POST['tel'];
        $insertId = Db::table('appoint')->insert(array('phone'=>$tel));
        if( $insertId ) {
            echo 1;die;
        }else{
            echo 0;die;
        }
    }
    public function about($id='',$about=''){
        $info = Db::table('config')->where(['id'=>$id])->find();
        // 热门车型

        $list = Db::table('lists')->where(['hot'=>1])->limit(9)->select();
        $about = empty($about)?'':$about;
        $this->assign('list',$list);
        $this->assign('web_title',$about);
        $this->assign('info',$info);
        return $this->fetch();
    }
}